package xyz.xtt.exchange.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Parameters;
import io.swagger.v3.oas.annotations.media.Schema;
import xyz.xtt.exchange.response.OrderResponse;
import xyz.xtt.exchange.service.TblAssetTransactionService;
import xyz.xtt.exchange.utils.ApiResult;

@Schema(name = "下单返回对象", description = "下单返回对象")
@RestController
@RequestMapping("/api/exchange")
public class OrderController {
	/**
	 * 下单接口
	 */
	@Autowired
	private TblAssetTransactionService tblAssetTransactionService;

	@Operation(summary = "下单接口")
	@Parameters({ @Parameter(name = "uid", description = "用户id", required = true),
			@Parameter(name = "assetId", description = "资产id", required = true) })
	@PostMapping("/order")
	public ApiResult<OrderResponse> order(@RequestHeader("uid") String uid, Long assetId) {
		OrderResponse order = tblAssetTransactionService.order(uid, assetId);
		
		return ApiResult.ok(order);
	}
}
